package com.apesource.project02.controller;

import com.apesource.project02.pojo.Message;
import com.apesource.project02.pojo.Registration;
import com.apesource.project02.pojo.Result;
import com.apesource.project02.pojo.User;
import com.apesource.project02.service.IMessageService;
import com.apesource.project02.service.IRegistrationService;
import com.apesource.project02.service.IResultService;
import com.apesource.project02.service.IUserServer;
import com.apesource.project02.util.ResponseEntity;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @auther:暮雪
 * @date:2025/9/18
 */
@RestController
@RequestMapping("/user")
@Api(tags = "user模块的相关接口",value = "/user",description = "这个模块管理user相关的所有接口信息")
public class UserController {
    @Autowired
    private IUserServer userServer;


    @PostMapping
    @ApiOperation(value = "注册用户")
    public ResponseEntity<User> register(@RequestBody User user) {

        return userServer.registerUser(user);
    }

    @GetMapping("/{userId}")
    @ApiOperation(value = "根据用户id查询用户")
    public ResponseEntity<User> getUserById(@PathVariable int userId) {
        return userServer.findUserById(userId);
    }

    @PutMapping
    @ApiOperation("修改用户相关信息")
    public ResponseEntity<User> updateUser(@RequestBody User user) {
        return userServer.updateUser(user);
    }

    @DeleteMapping("/{userId}")
    @ApiOperation("根据id删除用户信息")
    public ResponseEntity<User> deleteUser(@PathVariable int userId) {
        return userServer.deleteUser(userId);
    }

}
